package com.qianfeng.openapi.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/12/29
 * @Time: 上午10:32
 */
@Configuration
public class ElasticSearchConfig {

    @Value("${spring.data.elasticsearch.host}")
    private   String  host;

    @Value("${spring.data.elasticsearch.port}")
    private   int  port;


    @Bean
    public  RestHighLevelClient createClient() {
        HttpHost httpHost = new HttpHost(host, port);
        RestClientBuilder builder = RestClient.builder(httpHost);
        RestHighLevelClient client = new RestHighLevelClient(builder);
        return client;
    }




}
